package cn.edu.lzzy.mypractices.repository;

import cn.edu.lzzy.mypractices.entity.Chapter;
import cn.edu.lzzy.mypractices.entity.Course;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.UUID;

public interface ChapterRepository extends JpaRepository<Chapter, UUID> {
    //获取指定课程下的所有章节并以更新时间排序
    List<Chapter> findAllByCourseOrderByUpdateTimeDesc(Course course);
    List<Chapter> findAllByCourseIdOrderByUpdateTimeDesc(UUID courseId);

    // 获取指定课程下的章节数量
    Integer countAllByCourse(Course course);
    Integer countAllByCourseId(UUID course_id);

    //获取指定课程下的所有章节并分页
    List<Chapter> findAllByCourseOrderByUpdateTimeDesc(Course course, Pageable pageable);
    List<Chapter> findAllByCourseIdOrderByUpdateTimeDesc(UUID courseId, Pageable pageable);

}
